﻿// =================================================================== 
// Module说明
//====================================================================
// 创建时间：2018-12-13 15:47:19
// 负责人：Sushee
// ===================================================================
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq.Expressions;
using OF.Utility;
using OF.Component.Model;
using OF.Component.IDAL;
using OF.Component.Factory;
namespace OF.Component.BLL
{
	
	/// <summary>
	/// 扩展
	/// </summary>
	public partial class AuthoritySystemOperate
	{
        /// <summary>
    	/// 根据断言条件获取单个
    	/// </summary>
        public static AuthoritySystemInfo QuerySingle(Expression<Func<AuthoritySystemInfo, bool>> predicate)
        {
            return dal.QuerySingle(predicate);
        }
        /// <summary>
    	/// 根据断言条件获获取列表
    	/// </summary>
        public static IList<AuthoritySystemInfo> QueryList(Expression<Func<AuthoritySystemInfo, bool>> predicate)
        {
            return dal.QueryList(predicate);
        }

        /// <summary>
        /// 根据用户ID获取所对应系统信息
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static IList<AuthoritySystemInfo> GetSystemInfoByUserId(int userId)
        {
            List<int> roleList = new List<int>();
            IList<AuthorityUserRoleRelaInfo> list = AuthorityUserRoleRelaOperate.QueryList(a => a.IsActive == 1 && a.UserID == userId);
            foreach (var item in list)
            {
                roleList.Add(item.RoleID);
            }
            return dal.GetSystemInfoByRoleIds(roleList);
        }
    }
}